package com.collectionday03demo;

import java.util.ArrayList;
import java.util.Collections;

public class CollectionDemo {
    public static void main(String[] args) {
        ArrayList<Point> s = new ArrayList<>();
        ArrayList<Object> ss = new ArrayList<>();
        //这里会自动装箱  等同于 new integer(1)
        ss.add(1);



        Point point1 = new Point();
        s.add(point1);
        point1.setX(10);
        System.out.println(s);
        System.out.println( point1);


        Point point2 = new Point(100, 200);
        Point point3 = new Point(200, 300);
        Point point4 = new Point(300, 400);
        Point point5 = new Point(400, 500);

        //添加元素

        s.add(point2);
        s.add(point3);
        s.add(point4);
        s.add(point5);

        int ii = s.indexOf(new Point(100, 200));
        System.out.println(ii);

        //contains 比较 没改写对象里的equals方法比较地址值 改写后比较的属性
        boolean contains = s.contains(new Point(100, 200));
        System.out.println(contains);

        //remove  删除相应对象 删除一次
        s.remove(point5);


        for (int i = 0; i < s.size(); i++) {
            System.out.print(s.get(i) + " ");
        }
        //判断是否为空集
        //System.out.println(s.isEmpty());
        //清空集合
        //s.clear();
        //System.out.println(s.isEmpty());
        //集合长度
        //System.out.println(s.size());
    }
}
